function varargout = Flow_browser(varargin)
% FLOW_BROWSER M-file for Flow_browser.fig
%      FLOW_BROWSER, by itself, creates a new FLOW_BROWSER or raises the existing
%      singleton*.
%
%      H = FLOW_BROWSER returns the handle to a new FLOW_BROWSER or the handle to
%      the existing singleton*.
%
%      FLOW_BROWSER('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in FLOW_BROWSER.M with the given input arguments.
%
%      FLOW_BROWSER('Property','Value',...) creates a new FLOW_BROWSER or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Flow_browser_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Flow_browser_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help Flow_browser

% Last Modified by GUIDE v2.5 17-Oct-2009 00:42:59

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @Flow_browser_OpeningFcn, ...
                   'gui_OutputFcn',  @Flow_browser_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before Flow_browser is made visible.
function Flow_browser_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to Flow_browser (see VARARGIN)

% Choose default command line output for Flow_browser
handles.output = hObject;
handles.connection = myblob_open ('msferry', '2pueblos', 'localhost', 'mf_experiments');
% Update handles structure
guidata(hObject, handles);

% UIWAIT makes Flow_browser wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Flow_browser_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;



function edit1_Callback(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double


% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
query=get(handles.edit1,'String');
handles.results = myblob_command(handles.connection,query)';
set(handles.uitable1,'Data',handles.results);
guidata(hObject, handles);

% --- Executes during object deletion, before destroying properties.
function figure1_DeleteFcn(hObject, eventdata, handles)
% hObject    handle to figure1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
%handles.results
for i=1:length(handles.results(:,1))
   % i
    %[handles.results{i,9} handles.results{i,8}]
    [handles.flowData{i}, handles.flowParams{i}]=fca_readfcs([handles.results{i,9} handles.results{i,8}]);
    flowParamsCellArray=struct2cell(rmfield(handles.flowParams{i},'par'));
    for j=1:length(flowParamsCellArray)
        flowParamsCellFormat{i,j}=flowParamsCellArray{j};
    end
end

%handles.flowParams
set(handles.uitable1,'Data',flowParamsCellFormat);
%flowParamsCellFormat
guidata(hObject, handles);
